package com.automapper.sqlfragment;

import javax.persistence.criteria.JoinType;

import com.automapper.constants.FetchMode;
import com.automapper.criterion.ExpressionContext;
import com.automapper.sqlfragment.impl.SubQuerySqlFragment;
import com.automapper.sqlfragment.impl.TableSqlFragment;
import com.automapper.utils.ObjectFacade;

public class SqlFragmentFactory {

	public static TableFragment getTableFragment(ExpressionContext context, ObjectFacade objectFacade,
			String table, String alias, FetchMode fetchMode, JoinType joinType) {
		if (FetchMode.ASSOCIATION_PAGE_BY_PARENT.equals(fetchMode)) {
			return new SubQuerySqlFragment(context, objectFacade, table, alias);
		} else if (FetchMode.DEFAULT.equals(fetchMode)) {
			return new TableSqlFragment(table, alias);
		}
		return null;
	}
}
